<?php require_once("includes/security.php"); ?>	
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>קליניקה נטורופתית</title>

<?php 	
require_once("includes/initializeSession.php");
require("includes/openConnection.php");

if(isset($_POST['submit'])) 
	{
		
		if($_POST['submit']=="שלח")
			{
				if(mysql_query("INSERT INTO quiz (`id`, `qstn`) VALUES (NULL, '{$_POST['qst']}');"))
				echo "השאלה התווספה בהצלחה";
				else
				echo "השאלה לא התווספה בהצלחה";
			}
			
			else if($_POST['submit']=="מחק")
			{
				if(isset($_POST['qusID']))
				{
				$qusID=$_POST ['qusID'];
				if(mysql_query("DELETE FROM quiz WHERE ID ='$qusID'"))
							echo "שאלה נמחקה בהצלחה";
							else
							echo "השאלה לא נמחקה";
				}
			}
		
				
}//end submit
	

?>

</head>

<body>
<container id="container">
  <?php require("header.php"); ?>
      <content id="content">
      <contentTitle id="contentTitle">
      עריכת שאלון רפואי
      </contentTitle>
      <contentText id="contentText">
    			
<form name="form" action="#" method="post" enctype="multipart/form-data">
<table >
            <td>
           שאלה:
            </td>
            <td >
             <input type="text"  id="qst" name="qst" value="" size="120" >
            <td>
   		</tr>
        <tr>
            <td>
            <input type="submit" name="submit" value="שלח" /> 
            </td>
    	</tr>
</table>
</form>
    
 <subContentTitle id="subContentTitle">שאלות לשאלון</subContentTitle>	
 
<?php
$result = mysql_query("SELECT * FROM quiz")or die ('אין דף כזה'.mysql_error());
			while($row = mysql_fetch_array($result))
			{
		echo "
		<form name=form action=# method=post enctype=multipart/form-data>
		<table id=qus >
        <tr>
            <td>
         שאלה  :
            </td>
            <td >
             {$row['qstn']}
			 
			 <input type=hidden name=qusID id=qusID value={$row['id']}>
			<input type=submit name=submit value=מחק /> 
			 
            <td>
   		</tr>
		</table>  
		</form>
		";
			}
require("includes/closeConnection.php");	
?>
 
</contentText>
      </content>
</container>
    
     
    
</body>
</html>
